/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityBeans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author BELALOUACHE
 */
@Entity
@Table(name = "productsstore")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Productsstore.findAll", query = "SELECT p FROM Productsstore p"),
    @NamedQuery(name = "Productsstore.findByReferenceStore", query = "SELECT p FROM Productsstore p WHERE p.referenceStore = :referenceStore"),
    @NamedQuery(name = "Productsstore.findByName", query = "SELECT p FROM Productsstore p WHERE p.name = :name"),
    @NamedQuery(name = "Productsstore.findByAdress", query = "SELECT p FROM Productsstore p WHERE p.adress = :adress")})
public class Productsstore implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "reference_store")
    private Integer referenceStore;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Adress")
    private String adress;
    @JoinColumn(name = "id_account_fk", referencedColumnName = "id_account")
    @ManyToOne(optional = false)
    private Accounts idAccountFk;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProductsstoreFk")
    private Collection<Products> productsCollection;

    public Productsstore() {
        super();
    }

    public Productsstore(Integer referenceStore) {
        super();
        this.referenceStore = referenceStore;
        
    }

    public Productsstore(Integer referenceStore, String name, String adress) {
        super();
        this.referenceStore = referenceStore;
        this.name = name;
        this.adress = adress;
    }

    public Integer getReferenceStore() {
        return referenceStore;
    }

    public void setReferenceStore(Integer referenceStore) {
        this.referenceStore = referenceStore;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public Accounts getIdAccountFk() {
        return idAccountFk;
    }

    public void setIdAccountFk(Accounts idAccountFk) {
        this.idAccountFk = idAccountFk;
    }

    @XmlTransient
    public Collection<Products> getProductsCollection() {
        return productsCollection;
    }

    public void setProductsCollection(Collection<Products> productsCollection) {
        this.productsCollection = productsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (referenceStore != null ? referenceStore.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Productsstore)) {
            return false;
        }
        Productsstore other = (Productsstore) object;
        if ((this.referenceStore == null && other.referenceStore != null) || (this.referenceStore != null && !this.referenceStore.equals(other.referenceStore))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityBeans.Productsstore[ referenceStore=" + referenceStore + " ]";
    }
    
}
